<template>
  <div>
    <el-form :model="dataForm" ref="dataForm" label-width="100px" size="small" :rules="rules">
      <el-form-item label="目标月份:" prop="roleName">
        <el-input v-model="dataForm.roleName" placeholder="请输入职务名称" disabled clearable></el-input>
      </el-form-item>
      <el-form-item label="姓名:" prop="roleCode">
        <el-input v-model="dataForm.roleCode" placeholder="请输入职务编码" disabled clearable></el-input>
      </el-form-item>
      <el-form-item label="申请笔数:" prop="roleDesc">
        <el-input v-model="dataForm.roleDesc" type="text" placeholder="请输入1-9999之间的整数" clearable></el-input>
      </el-form-item>
      <el-form-item label="授信户数:" prop="roleDesc">
        <el-input v-model="dataForm.roleDesc" type="text" placeholder="请输入1-9999之间的整数" clearable></el-input>
      </el-form-item>
      <el-form-item label="放款金额:" prop="roleDesc">
        <el-input v-model="dataForm.roleDesc" type="text" placeholder="请输入1-99999999之间的整数" clearable></el-input>
      </el-form-item>
      <el-form-item style="margin-top: 10px" label-width="130px">
        <el-button @click="close">
          <fa-icon class="fa-times" />取消
        </el-button>
        <el-button type="primary" @click="submit">
          <fa-icon class="fa-check" />提交
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import { CONSTANT_OBJ } from '@/utils/constant'
import { common } from '@/utils/common'
// import api from '../api'
export default {
  props: { editData: Object },
  data () {
    return {
      dataForm: {
        roleId: '',
        roleCode: '',
        roleName: '',
        roleDesc: ''
      },
      rules: {
        roleCode: [{ required: true, message: '请输入职务编码', trigger: 'blur' }],
        roleName: [{ required: true, message: '请输入职务名称', trigger: 'blur' }]
      }
    }
  },
  mounted () {
    if (this.editData && this.editData.roleId) {
      common.listAssign(this.dataForm, this.editData)
    }
  },
  methods: {
    close () {
      this.$emit('closeEditor', false)
    },
    /**
     * 提交代码
     */
    submit () {
    //   this.$refs['dataForm'].validate((valid) => {
    //     if (valid) {
    //       if (this.editData && this.editData.roleId) {
    //         this.editUser()
    //       } else {
    //         this.addUser()
    //       }
    //     }
    //   })
    },
    // 新增
    addUser () {
    //   api.postAddRoleData(this.dataForm).then(res => {
    //     const { responseCode, responseMsg } = res
    //     if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
    //       this.$message({
    //         message: `${responseMsg}`,
    //         type: 'success'
    //       })
    //       this.$emit('uppdataSuccess', 'role')
    //     }
    //   })
    },
    // 编辑
    editUser () {
    //   api.postAddRoleData(this.dataForm).then(res => {
    //     const { responseCode, responseMsg } = res
    //     if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
    //       this.$message({
    //         message: `${responseMsg}`,
    //         type: 'success'
    //       })
    //       this.$emit('uppdataSuccess', 'role')
    //     }
    //   })
    }
  }
}
</script>
